import ActionTypes from '../config/ActionTypes';
import ActionCodes from '../config/ActionCodes';
import { postFetch, getFetch } from '../utils/network/request/HttpExtension.js';
import { createAction } from 'redux-actions';
import Session from '../utils/SessionUtils';
import { AsyncStorage } from 'react-native';

export function FetchNewsList(categoryId, userId, currentPage = 0,paramTitle = '', pageSize = 10) {
	return dispatch => {
		dispatch({ type: ActionTypes.NEWSLIST + ActionTypes.FETCH_LOADING_SUFFIX });


		let currentPage = '';
		let param = {
			SearchType: '0',
			CATEGORY_ID: categoryId,
			TITLE: paramTitle,
			PageIndex: currentPage,
			PageSize: '10',
			SortBy: 'AUDIT_DATE DESC',
		};

		postFetch(ActionCodes.contactList, param)
			.then(res => {
				dispatch({
					type: ActionTypes.NEWSLIST + ActionTypes.FETCH_SUCCESS_SUFFIX
				});
			})
			.catch(err => {
				alert(err);
				dispatch({ type: ActionTypes.NEWSLIST + ActionTypes.FETCH_ERROR_SUFFIX });
			});
	};
}
